<?php
// Copyright 2019 Hackware SpA <human@hackware.cl>
// This file is part of "Hackware Web Services Wallet" and licensed under
// the terms of the GNU Affero General Public License version 3, or (at your
// option) a later version. You should have received a copy of this license
// along with the software. If not, see <https://www.gnu.org/licenses/>.

namespace Hawese\Wallet\Providers;

use Illuminate\Support\ServiceProvider;

class WalletServiceProvider extends ServiceProvider
{
    const BASEDIR = __DIR__ . '/../..';

    public function register()
    {
        $this->mergeConfigFrom(
            self::BASEDIR . '/config/wallet.php',
            'wallet'
        );
    }

    public function boot()
    {
        $this->loadRoutesFrom(self::BASEDIR . '/routes/wallet.php');
        $this->loadMigrationsFrom(self::BASEDIR . '/database/migrations');
        $this->loadViewsFrom(self::BASEDIR . '/resources/views', 'wallet');

        // Policies
        $this->app['gate']->policy(
            Hawese\Wallet\Wallet::class,
            Hawese\Wallet\Policies\WalletPolicy::class
        );
        $this->app['gate']->policy(
            Hawese\Wallet\Transaction::class,
            Hawese\Wallet\Policies\TransactionPolicy::class
        );
    }
}
